home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 134 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
  2. Message-ID: <9601250655.8394@mulga.cs.mu.OZ.AU>
  3. X-Original-Date: Thu, 25 Jan 1996 17:55:54 +1100
  4. Path: in2.uu.net!bounce-back
  5. Date: 25 Jan 96 07:40:17 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Why no allocator-specific delete?
  9. Organization: Computer Science, University of Melbourne, Australia
  10. References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM>
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMQcz8eEDnX0m9pzZAQHcagF/TDs98kUv8id6nGgFFktQR7LHQ0vfYBxi
  13.     WVQ1O+jdzCzDFfbKYab5KIg6zxAjQV0f
  14.     =dE18
  15.  
  16. clamage@Eng.Sun.COM (Steve Clamage) writes:
  17.  
  18. >David Byrden <100101.2547@compuserve.com>
  19. >writes:
  20. >>Why, in the Septenber draft standard, is an allocator-specific verrion of 
  21. >>'new' provided;
  22. >>
  23. >>20.1.4.4
  24. >>
  25. >>           new(x) T    
  26. >>
  27. >>    returns an X::types<T>::pointer, where x is of an 
  28. >>    allocator type X
  29. >
  30. >You are actually referring to the "placement new" syntax not having a
  31. >corresponding "placement delete" syntax.
  32.  
  33. No; that's part of the issue, but there is also a question of why
  34. allocators are not required to define an operator delete() function.
  35. If I write
  36.  
  37.     new (x) T
  38.  
  39. where x is an allocator, and the constructor for T throws an
  40. exception, does x.deallocate() get called?  According to the
  41. September draft, I don't think it does -- and that is a real
  42. problem.
  43.  
  44. There also appears to be another problem with
  45.  
  46.     new (x) T[n];
  47.  
  48. The supposed semantics of this are
  49.  
  50.     new((void*)x.template allocate<T>(n)) T[n]
  51.  
  52. However, that may have undefined behaviour!
  53. The reason is that it may not allocate enough memory.
  54. It is only guaranteed to allocate enough memory to hold
  55. `n' objects of type `T'.  However, the compiler
  56. need additional space for ``array allocation overhead''
  57. (see [expr.new]).
  58.  
  59. --
  60. Fergus Henderson                 WWW: http://www.cs.mu.oz.au/~fjh
  61. fjh@cs.mu.oz.au                  PGP: finger fjh@128.250.37.3
  62. ---
  63. [ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  64.   Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  65.   is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
  66.